/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package rinoa;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 *
 * @author fcarou
 */
public class Rinoa implements ServletContextListener
{
    private static Thread hilo;

    public Rinoa ()
    {
        System.out.println("Constructor...");
    }
    
    @Override
    public void contextInitialized(ServletContextEvent sce)
    {
        System.out.println("Hola mundo!");
        
        hilo = new Thread (new Hilo());
        hilo.start();
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce)
    {
        hilo.interrupt();
        System.out.println("Chau mundo!");
    }
    
    private class Hilo implements Runnable
    {
        
        @Override
        public void run ()
        {
            try
            {
                for (int i = 0; i < 10; i++)
                {
                    System.out.println("Hola!! " + i);
                    Thread.sleep(90000);
                }
            }
            catch (InterruptedException ex)
            {
                
            }
        }
    }
}
